<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/header.jsp"%>
<%
	String title = "信息综合系统";
%>
<title><%=title%>-经理签到情况</title>
<head>
<script type="text/javascript">
	//获取浏览器页面可见高度和宽度
	var _PageHeight = document.documentElement.clientHeight, _PageWidth = document.documentElement.clientWidth;
	//计算loading框距离顶部和左部的距离（loading框的宽度为215px，高度为61px）
	var _LoadingTop = _PageHeight > 61 ? (_PageHeight - 61) / 2 : 0, _LoadingLeft = _PageWidth > 215 ? (_PageWidth - 215) / 2
			: 0;
	//在页面未加载完毕之前显示的loading Html自定义内容
	var _LoadingHtml = '<div id="loadingDiv" style="position:absolute;left:0;width:100%;height:'
			+ _PageHeight
			+ 'px;top:0;background:white;opacity:1;filter:alpha(opacity=80);z-index:10000;"><div style="position: absolute; cursor1: wait; left: '
			+ _LoadingLeft
			+ 'px; top:'
			+ _LoadingTop
			+ 'px; width: auto; height: 57px; line-height: 57px; padding-left: 50px; padding-right: 5px; background: #fff url(${pageContext.request.contextPath}/img/loading.gif) no-repeat scroll 5px 10px; border: 2px solid #95B8E7; color: #696969; font-family:\'Microsoft YaHei\';">页面加载中，请等待......</div></div>';
	//呈现loading效果
	document.write(_LoadingHtml);
	//监听加载状态改变
	document.onreadystatechange = completeLoading;
	//加载状态为complete时移除loading效果
	function completeLoading() {
		if (document.readyState == "complete") {
			var loadingMask = document.getElementById('loadingDiv');
			loadingMask.parentNode.removeChild(loadingMask);
		}
	}
</script>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-itunes-app" content="app-id=429849944" />
<meta name="apple-touch-fullscreen" content="no" />
<meta content="telephone=no" name="format-detection" />
<meta name="apple-mobile-web-app-capable" content="no" />
</head>
<!-- BEGIN BODY -->
<body class="fixed-top"
	style="margin-top: 0px; padding: 0px !important; overflow: auto;">

	<jsp:include page="/common/headerPage.jsp"></jsp:include>
	<!-- BEGIN CONTAINER 容器 -->
	<div id="container" class="row-fluid">
		<jsp:include page="/common/left.jsp" />
		<div id="main-content">
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<h3 class="page-title">经理签到情况</h3>
						<ul class="breadcrumb">
							<li><a
								href="${pageContext.request.contextPath}/user/index.do">首页</a> <span
								class="divider">/</span></li>
							<li class="active">经理签到情况</li>
						</ul>
					</div>
				</div>
				<!-- BEGIN EDITABLE TABLE widget-->
				<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN EXAMPLE TABLE widget-->
						<div class="purple">
							<div class="widget-body" style="height: 400px; overflow: auto;">
								<div>
									<div class="btn-group pull-right"
										style="position: absolute; top: 180; right: 40;">
										<button class="btn dropdown-toggle" data-toggle="dropdown">
											更多 <i class="icon-angle-down"></i>
										</button>
										<ul class="dropdown-menu pull-right">
											<li><a href="#">下载模板</a></li>
											<li><a onclick="ajaxDownLoadSignIn();">下载已筛选记录</a></li>
											<li><a href="#">上传</a></li>
										</ul>
									</div>
									<div class="clearfix">
										<input type="text" id="startDate" value='2018/04/07'
											class="Wdate" style="width: 120px;"
											onfocus="WdatePicker({dateFmt:'yyyy/MM/dd',maxDate:'#F{$dp.$D(\'endDate\')}',lang:'zh-cn',readOnly:true})"
											placeholder="请填写开始时间" /> <input type="text" id="endDate"
											value='2018/04/09' class="Wdate" style="width: 120px;"
											onfocus="WdatePicker({dateFmt:'yyyy/MM/dd',minDate:'#F{$dp.$D(\'startDate\')}',lang:'zh-cn',readOnly:true})"
											placeholder="请填写结束时间" /> <input type="button" id="seach"
											name="seach" value="查询" class="btn  btn-primary"
											style="margin-bottom: 10px;" onclick="ajaxGetSignIn(1,8);">
									</div>

									<table class="table table-striped table-hover table-bordered"
										id="editable-sample">
										<thead>
											<tr>
												<th width="8%">姓名</th>
												<th width="8%">签到日期</th>
												<th width="5%">时间点</th>
												<th width="5%">星期</th>
												<th width="15%">地市</th>
												<th width="8%">区县</th>
												<th width="5%">勤劳分</th>
												<th width="15%">客户</th>
												<th width="4%">积分</th>
												<th width="5%">级别</th>
												<th width="8%">签到类型</th>
											</tr>
										</thead>
										<tbody id="distribute-body">
										</tbody>
									</table>

									<div class="pageBottom" style="text-align: center;">
										<input type="hidden" id="page-size" value="20" />
										<div id="callBackPager" class="paging_bootstrap pagination"></div>
										<div></div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--  <<<<<<< HEAD 是我的代码的开始
	>>>>>>> refs/remotes/origin/hehe 是其他分支的代码
	两个人的代码通过 =============隔开
	-->
	<!-- <<<<<<< HEAD
BEGIN FOOTER ccccc
=======
BEGIN FOOTER bbb
>>>>>>> refs/remotes/origin/hehe -->
	<jsp:include page="/common/footer.jsp"></jsp:include>
	<!-- END FOOTER aaa -->
	<!-- END FOOTER aaa Test Test Test-->
	<!-- BEGIN JAVASCRIPTS -->
	<!-- Load javascripts at bottom, this will reduce page load time -->
	<script src="js/jquery-1.8.3.min.js"></script>
	<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
	<script type="text/javascript" src="js/jquery.slimscroll.min.js"></script>
	<script src="js/fullcalendar.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/jquery.easy-pie-chart.js" type="text/javascript"></script>
	<script src="js/jquery.sparkline.js" type="text/javascript"></script>
	<script src="js/Chart.js"></script>
	<script src="js/jquery.scrollTo.min.js"></script>
	<!--common script for all pages-->
	<script src="js/common-scripts.js"></script>
	<script type="text/javascript" src="js/layer/layer.js"></script>
	<script type="text/javascript" src="js/extendPagination.js"></script>
	<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
		function openUploadModal() {
			$('#choosefile').modal();
		}

		//异步按条件查询经理签到记录
		function ajaxGetSignIn(pageNumber, pageSize) {
			var condiMap = {
				startTime : ($("#startDate").val()),
				endTime : $("#endDate").val(),
				pageNumber : pageNumber,
				pageSize : pageSize
			}
			layer.load(2);
			$.ajax({
				type : "POST",
				url : "signIn/showSignInList.do?t=" + Math.random(),
				data : condiMap,
				dataType : "json",
				success : function(result) {
					$(".pageBottom").css('display', 'none');
					if (result.code == -3) { //登录用户失效
						layer.alert(result.message + '</br>点击前往登录页面:'
								+ '<a href="login.jsp">登录页面</a>');
					} else if (result.total == 0) {
						layer.msg("筛选后的记录数为零！")
					} else {
						$("#distribute-body").html("");
						if (result.pageNum == 1) {
							$('#callBackPager').extendPagination({
								totalCount : result.total,
								showPage : 5,
								pageNum : result.pageNum,
								limit : result.pageSize,
								callback : function(curr, limit, totalCount) {
									ajaxGetSignIn(curr, limit);
								}
							});
						}
						$(".pageBottom").css('display', 'block');
						createTable(result.pageNum, result.pageSize,
								result.total, result.list);
						$("#pageNumber").text(result.pageNum);
					}

					layer.closeAll('loading');
				},
				error : function(e) {
					layer.closeAll('loading');
					layer.msg("请求服务器异常！");
				}
			});
		};

		//异步下载经理签到情况
		function ajaxDownLoadSignIn() {
			var condiMap = {
				startTime : ($("#startTime").val()),
				endTime : $("#endTime").val()
			}
			layer.load(2);
			$.ajax({
				type : "POST",
				url : "signIn/downLoadSignIn.do?t=" + Math.random(),
				data : condiMap,
				dataType : "json",
				success : function(result) {
					if (result.code == -3) { //登录用户失效
						layer.alert(result.message + '</br>点击前往登录页面:'
								+ '<a href="login.jsp">登录页面</a>');
					} else if (result.code == -4) {
						layer.alert("您没有操作权限！！！");
					} else if (result.sucessful == 1) {
						layer.msg("下载成功！");
					} else {
						layer.msg("下载失败！");
					}
					layer.closeAll('loading');
				},
				error : function(e) {
					layer.closeAll('loading');
					layer.msg("请求服务器异常！");
				}
			});
		};

		//动态创建table
		function createTable(currPage, limit, total, items) {
			var html = [], showNum = limit;
			if (total - (currPage * limit) < 0)
				showNum = total - ((currPage - 1) * limit);
			for (var i = 0; i < showNum; i++) {
				html.push('<tr><td>' + formatData(items[i].name) + '</td>');
				html.push('<td>' + formatData(items[i].riqi) + '</td>');
				html.push('<td>' + formatData(items[i].hour) + '</td>');
				html.push('<td>' + formatData(items[i].week) + '</td>');
				html.push('<td>' + formatData(items[i].shi) + '</td>');
				html.push('<td>' + formatData(items[i].qu) + '</td>');
				html.push('<td>' + formatData(items[i].sumfen) + '</td>');
				html.push('<td>' + formatData(items[i].client) + '</td>');
				html.push('<td>' + formatData(items[i].fen) + '</td>');
				html.push('<td>' + formatData(items[i].client_rang) + '</td>');
				html.push('<td>' + formatData(items[i].targetType) + '</td>');
				html.push('</tr>');
			}
			var mainObj = $('#distribute-body');
			mainObj.empty();
			mainObj.html(html.join(''));
		};
		//格式化无效数据
		function formatData(data) {
			if (data && data != null) {
				return data;
			} else {
				return "";
			}
		}

		//查询按钮绑定回车键
		$("body").keydown(function() {
			if (event.keyCode == "13") {//keyCode=13是回车键
				$('#seach').click();
			}
		});
	</script>
	<script>
		$(function() {
			// alert();
			var h = screen.height * 0.5;
			$(".modal").css("position", "relative");
			$(".modal").css("z-index", 0);
			$(".modal-body").css("height", h + 'px');
		});
	</script>
	<!-- END BODY -->
</body>
</html>